package com.bite.springblog.service;

import com.bite.springblog.mapper.BlogInfoMappper;
import com.bite.springblog.mapper.UserInfoMapper;
import com.bite.springblog.model.BlogInfo;
import com.bite.springblog.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

        @Autowired
        private UserInfoMapper userInfoMapper;
        @Autowired
        private BlogInfoMappper blogInfoMappper;


        public UserInfo queryByName(String userName){
            return userInfoMapper.queryByName(userName);
        }

        public UserInfo queryById(Integer userId) {
            return userInfoMapper.queryById(userId);
        }

        public UserInfo qetAuthorInfo(Integer blogId){
            BlogInfo blogInfo=blogInfoMappper.queryById(blogId);
            if(blogId==null||blogInfo.getUserId()<0){
                return null;
            }
            return userInfoMapper.queryById(blogInfo.getUserId());
        }
}
